import { View } from '@tarojs/components';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Taro from '@tarojs/taro';
import './index.less'

/**
 * 页面加载
 */
export default class PageLoading extends Component {
    static propTypes = {
        style: PropTypes.object,
        textStyle:   PropTypes.object,
    };

    static defaultProps = {
        style: {
            border: '8rpx solid #fff',
            borderTopColor: 'transparent !important'
        },
        textStyle: {
            color: '#fff'
        }
    };

    constructor(props) {
        super(props);
        this.state = {
            text: '加载资源中...'
        }
    }

    componentDidMount() {
  
    }

    render() {
        let { style, loadingText, textStyle } = this.props;
        style = {
            ...style,
            borderTopColor: 'transparent !important' // 必须要加
        }
        const { text } = this.state;
        console.log('index.tsx render style=', style)
        return (
            <>
                <View
                    className='loading' style={{ ...style }}></View>
                <View className='loadingText' style={{...textStyle }}>{loadingText ||text}</View>
            </>
        )
    }

}